package com.aps.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.aps.entity.ResultEntity;
import com.aps.entity.domain.dish.DishSpec;
import com.aps.page.BaseQuery;
import com.aps.service.IDishSpecService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author liaoguangan
 * @description <>
 * @date 2018/4/9 15:55
 */
@RestController
@RequestMapping("/manage-api")
@Api(value = "manage-dish-spec-api", description = "菜品规格管理接口")
public class DishSpecApi {

    ///////////////////////////菜品规格/////////////////////////

    @Autowired
    private IDishSpecService dishSpecService;

    @RequestMapping(value = "/list-specs", method = RequestMethod.POST)
    @ApiOperation("获取菜品规格列表")
    public ResultEntity listDishSpecs(@RequestBody BaseQuery baseQuery) {
        return new ResultEntity(dishSpecService.list(baseQuery));
    }

    @RequestMapping(value = "/dishSpec", method = RequestMethod.POST)
    @ApiOperation("增加获取菜品规格")
    public ResultEntity addDishSpecs(@RequestBody DishSpec dishSpec) {
        return new ResultEntity(dishSpecService.add(dishSpec));
    }

    @RequestMapping(value = "/dishSpec/{id}", method = RequestMethod.DELETE)
    @ApiOperation("删除获取菜品规格")
    public ResultEntity removeDishSpecs(@PathVariable("id") String id) {
        dishSpecService.remove(id);
        return new ResultEntity(true);
    }

    @RequestMapping(value = "/dishSpec", method = RequestMethod.PUT)
    @ApiOperation("修改获取菜品规格")
    public ResultEntity updateDishSpecs(@RequestBody DishSpec dishSpec) {
        return new ResultEntity(dishSpecService.update(dishSpec));
    }

    @RequestMapping(value = "/dishSpec/{id}", method = RequestMethod.GET)
    @ApiOperation("查询获取菜品规格")
    public ResultEntity getDishSpecs(@PathVariable("id") String id) {
        return new ResultEntity(dishSpecService.get(id));
    }
}
